package jdk.jdk8.lambda;

import org.junit.Test;

import java.util.Comparator;

/**
 * 语法格式五：多参数列表和多执行语句，并且有返回值
 *
 * @author guodd
 * @version 1.0
 */
public class Lambda06 {
    public static void main(String[] args) {
        new Thread(() -> System.out.println("java")).start();
    }

    @Test
    public void comparable01() {
        // 传统写法
        Comparator<Integer> cp = new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1.compareTo(o2);
            }
        };
        System.out.println(cp.compare(3, 1));
        // lambda写法
        Comparator<Integer> cc = (o1, o2) -> {
            return o1.compareTo(o2);
        };
    }
}
